package com.bdqn.struts.action;

import com.bdqn.struts.entity.Address;
import com.bdqn.struts.entity.User;
import com.opensymphony.xwork2.ActionSupport;

import java.util.ArrayList;
import java.util.List;

public class ShowArrayAndListAction extends ActionSupport {
    private String[] hobbies;
    private List<Double> numbers;
    private List<User> users;
    private User user;

    @Override
    public String execute() throws Exception {
        hobbies[0]="lisi";
        hobbies[1]="wangwu";

        users=new ArrayList<User>() ;
        user = new User() ;
        user.setName("jbit");
        user.setAge(23);
        Address address = new Address() ;
        address.setCountry(" China");
        address.setCity(" beijing" );
        address.setStreet("chengfu street" ) ;
        user.setAddress (address) ;
        users.add (user) ;
        user = new User() ;
        user.setName("bdqn");
        user.setAge(18);
        Address address2 = new Address() ;
        address2.setCountry("China") ;
        address2.setCity("beijing") ;
        address2.setStreet("haidian") ;
        user.setAddress(address) ;
        users.add(user) ;
        return SUCCESS;
    }

    public String[] getHobbies() {
        return hobbies;
    }

    public void setHobbies(String[] hobbies) {
        this.hobbies = hobbies;
    }

    public List<Double> getNumbers() {
        return numbers;
    }

    public void setNumbers(List<Double> numbers) {
        this.numbers = numbers;
    }

    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
